package com.ocom.mqsubsidy.controller;

import com.alibaba.fastjson.JSON;
import com.ocom.common.constant.MqPay;
import com.ocom.common.dto.MqPaymentCallBackDto;
import com.ocom.common.dto.SubsidyDto;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.common.vo.GrantSubsidyVo;
import com.ocom.mqsubsidy.business.subsidy.SubsidyProductService;
import com.ocom.mqsubsidy.business.zkzl.ZkzlProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class SubsidyController {


    @Autowired
    private SubsidyProductService subsidyProductService;

    @Autowired
    private ZkzlProductService zkzlProductService;

    @PostMapping(MqPay.URL_grantSubsidy)
    public Result grantSubsidy(@RequestBody GrantSubsidyVo grantSubsidyVo){
        String msg = JSON.toJSONString(grantSubsidyVo);
        subsidyProductService.handle(msg);
        return ResultUtil.success();
    }

    @PostMapping(MqPay.URL_ZkzlSendMsg)
    public Result sendMsg(@RequestBody MqPaymentCallBackDto dto){
        String msg = JSON.toJSONString(dto);
        zkzlProductService.sendMsg(msg);
        return ResultUtil.success();
    }

}
